fn convert_inner(num: &str, from_base: u32, to_base: u32) -> String {
    if num.len() as f64 <= (std::mem::size_of::<u64>() * 8) as f64 * 2f64.log(from_base as f64) {
        (0..).scan(num.chars().fold(0u64, |s, c| {
            s * from_base as u64 + c.to_digit(from_base).unwrap() as u64
        }), |tmp, i| {
            let rem = *tmp % to_base as u64;
            *tmp = *tmp / to_base as u64;
            Some(rem).filter(|x| *x != 0 || i == 0).map(|x| char::from_digit(x as u32, to_base).unwrap())
        }).collect::<String>().chars().rev().collect()
    } else {
        // num >= 2^64.
        // we can implement it by manually division.
        // but we don't implemnt it now.
        todo!()
    }
}

pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let mut tmp = num_str.split(|c| c == '(' || c == ')');
    (convert_inner(tmp.next().unwrap(), tmp.next().unwrap().parse().unwrap(), to_base)).to_string()
}
